package day0910.demo1;

import day0910.demo1.Animal;
import day0910.demo1.Cat;
import day0910.demo1.Dog;

/**
 * @Author:galaxy_yan
 * @Date: 2022/9/10
 * @Time: 17:00
 * @Description
 */
public class TextAnimal {

//    2.方法参数
    public static void eat(Animal an) {
        an.eat();
    }
//    3.返回值参数
    public static Animal buyAnimal(String name){
        if("狗"==name){
            return new Dog("blue",1);
        }else if("猫"==name){
            return new Cat("小七",1);
        }else{
            return null;
        }
    }

    public static void main(String[] args) {
//        1.直接赋值
        Dog dog=new Dog("小黑",2);
        Cat cat=new Cat("大白",2);

        eat(dog);
        eat(cat);

        Animal animal = buyAnimal("狗");
        animal.eat();
        animal = buyAnimal("猫");
        animal.eat();

    }
}

//    小狗小黑在吃狗粮
//    小猫大白在吃猫粮
//    小狗blue在吃狗粮
//    小猫小七在吃猫粮